use "actions T1 - T6.dta", clear

*** average payoff by treatment

gen payoff=.
replace payoff=70 if OwnAction==1  & OtherAction==1
replace payoff=80 if OwnAction==1  & OtherAction==2
replace payoff=110 if OwnAction==1  & OtherAction==3
replace payoff=0 if OwnAction==2  & OtherAction==1
replace payoff=90 if OwnAction==2  & OtherAction==2
replace payoff=110 if OwnAction==2  & OtherAction==3
replace payoff=0 if OwnAction==3  & OtherAction==1
replace payoff=0 if OwnAction==3  & OtherAction==2
replace payoff=100 if OwnAction==3  & OtherAction==3


tab treatment, sum(payoff) nofreq 


gen A=OwnAction==1
gen B=OwnAction==2
gen C=OwnAction==3

*** Table 2

tab OwnAction treatment, column


**** Table B1

gen PPeriod=1
replace PPeriod=2 if Period>10
replace PPeriod=3 if Period>20
replace PPeriod=4 if Period>30

sort treatment
by treatment: tab OwnAction PPeriod, column

sort treatment Period

by treatment Period: egen freqA=mean(A) 
by treatment Period: egen freqB=mean(B) 
by treatment Period: egen freqC=mean(C) 

***  Figure 3

scatter freqA freqB freqC Period, by(treatment, row(3)) connect(l l l) msize( 1 1 1)

sort session MatchingGroup

egen MatchingGroup1=group(session MatchingGroup) if treatment==1
egen MatchingGroup2=group(session MatchingGroup) if treatment==2
egen MatchingGroup3=group(session MatchingGroup) if treatment==3
egen MatchingGroup4=group(session MatchingGroup) if treatment==4
egen MatchingGroup5=group(session MatchingGroup) if treatment==5
egen MatchingGroup6=group(session MatchingGroup) if treatment==6


replace MatchingGroup=MatchingGroup1 if treatment==1
replace MatchingGroup=MatchingGroup2 if treatment==2
replace MatchingGroup=MatchingGroup3 if treatment==3
replace MatchingGroup=MatchingGroup4 if treatment==4
replace MatchingGroup=MatchingGroup5 if treatment==5
replace MatchingGroup=MatchingGroup6 if treatment==6

sort treatment MatchingGroup Period

drop freqA freqB freqC

by treatment MatchingGroup Period: egen freqA=mean(A) 
by treatment MatchingGroup Period: egen freqB=mean(B) 
by treatment MatchingGroup Period: egen freqC=mean(C) 

**** Figure B1

scatter freqA freqB freqC Period, by(treatment MatchingGroup, row(6)) connect(l l l) msize( 1 1 1)

*****  Table B2

sort treatment  MatchingGroup
by treatment : tab MatchingGroup OwnAction, row



****TEST

sort  treatment MatchingGroup
by treatment MatchingGroup: egen fA=mean(A) 
by treatment MatchingGroup: egen fB=mean(B) 
by treatment MatchingGroup: egen fC=mean(C) 

by treatment MatchingGroup: egen pay=mean(payoff) 



sort  treatment MatchingGroup
by  treatment MatchingGroup: gen test=1 if _n==1



*** TEST network Clust vs NoClust
ranksum fC, by(treatment), if (treatment==1|treatment==2)&test==1
ranksum fC, by(treatment), if (treatment==3|treatment==4)&test==1
ranksum fC, by(treatment), if (treatment==5|treatment==6)&test==1

ranksum pay, by(treatment), if (treatment==1|treatment==2)&test==1
ranksum pay, by(treatment), if (treatment==3|treatment==4)&test==1
ranksum pay, by(treatment), if (treatment==5|treatment==6)&test==1


*** TEST no communication vs Bare communication

ranksum fC, by(treatment), if (treatment==1|treatment==3)&test==1
ranksum fC, by(treatment), if (treatment==2|treatment==4)&test==1

ranksum pay, by(treatment), if (treatment==1|treatment==3)&test==1
ranksum pay, by(treatment), if (treatment==2|treatment==4)&test==1



*** TEST Rich communication vs Bare communication

ranksum fC, by(treatment), if (treatment==5|treatment==3)&test==1
ranksum fC, by(treatment), if (treatment==6|treatment==4)&test==1

ranksum pay, by(treatment), if (treatment==5|treatment==3)&test==1
ranksum pay, by(treatment), if (treatment==6|treatment==4)&test==1


*** TEST Rich communication vs no communication

ranksum fC, by(treatment), if (treatment==5|treatment==1)&test==1
ranksum fC, by(treatment), if (treatment==6|treatment==2)&test==1






